package leetcode;

import java.util.*;

public class LeetcodeMain88 {

    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        while (in.hasNext()){
            String str=in.nextLine();
            String[] arr=str.split(" ");
            int count=0;
            String str1=arr[arr.length-2];
            char[] chars=str1.toCharArray();
            Arrays.sort(chars);
            String string=String.valueOf(chars);
            List<String> list=new ArrayList<>();
            for (int i = arr.length-3; i >=1 ; i--) {
                String st=arr[i];
                char[] chars1=st.toCharArray();
                Arrays.sort(chars1);
                String st1=String.valueOf(chars1);
                if (st1.equals(string)){
                    if (str1.equals(st)){
                        continue;
                    }else {
                        count++;
                        list.add(st);
                    }
                }else {
                    continue;
                }
            }
            Collections.sort(list,((o1, o2) -> o1.compareTo(o2)));
            System.out.println(count);
            if (Integer.parseInt(arr[arr.length-1])<=list.size()){
                System.out.println(list.get(Integer.parseInt(arr[arr.length-1])-1));
            }

        }
    }
    public static void main1(String[] args) {
        Scanner in=new Scanner(System.in);
        while (in.hasNext()){
            String str=in.nextLine();
            String[] arr=str.split(" ");
            Map<Character, Integer> map=new HashMap<>();
            for (int i = 0; i < arr[0].length(); i++) {
                char ch=arr[0].charAt(i);

                map.put(ch,map.getOrDefault(ch,0)+1);
            }
            boolean flag=true;
            for (int i = 0; i < arr[1].length(); i++) {
                char ch=arr[1].charAt(i);
                if (!map.containsKey(ch)){
                    flag=false;
                    break;
                }else {
                    int count=map.get(ch);
                    if (count==0){
                        flag=false;
                        break;
                    }else {
                        map.put(ch,count-1);
                    }
                }
            }
            if (flag&&arr[0].length()>=arr[1].length()){
                System.out.println("Yes");
            }else {
                System.out.println("No");
            }
        }
    }
}
